/**
 * 
 */
package org.rk.core.common.bean;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author cavion
 * @类描述：数据分页实体
 * 2015年11月18日 下午9:18:11
 */
public class PageData implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6267206676156798995L;
	
	private int start;//开始数据是第几条
	private Long pageTotal;//总页数
	private int length;//每页显示数量
	private Long recordsTotal;//当前查询条件的数据总数
	private Long recordsFiltered;//过滤后的总记录数
	private int draw;//操作次数
	private List<Map<String,Object>> data;//数据集
	public PageData(){
		this.pageTotal=1L;
		this.recordsTotal=0L;
		this.recordsFiltered=0L;
	}
	public Long getPageTotal() {
		return pageTotal;
	}
	public void setPageTotal(){
		if(this.pageTotal==null||this.pageTotal<1){
			if(recordsTotal%this.length==0){
				this.pageTotal=this.recordsTotal/this.length;
			}else{
				this.pageTotal=this.recordsTotal/this.length+1;
			}
		}
	}
	public void setPageTotal(Long pageTotal) {
		this.pageTotal = pageTotal;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		if(length<1||length>1000){
			this.length=10;//没有初始10条
		}
		this.length = length;
	}
	
	public Long getRecordsTotal() {
		return recordsTotal;
	}
	public void setRecordsTotal(Long recordsTotal) {
		this.recordsTotal = recordsTotal;
		setPageTotal();//设置总记录以后，同时计算总页数
		setRecordsFiltered(recordsTotal);//设置过滤后记录数，默认总记录数
	}
	public Long getRecordsFiltered() {
		return recordsFiltered;
	}
	public void setRecordsFiltered(Long recordsFiltered) {
		this.recordsFiltered = recordsFiltered;
	}
	public int getDraw() {
		return draw;
	}
	public void setDraw(int draw) {
		this.draw = draw;
	}
	public List<Map<String,Object>> getData() {
		return data;
	}
	public void setData(List<Map<String,Object>> data) {
		this.data = data;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}

	
}
